#!/usr/bin/python3


try:
    t = int(input())
    for x in range(t):
        y, m, d = map(int, input().split())
        if (m == 9 and d == 30) or (m == 1 and d == 30) or ((m + d) % 2 == 0):
            print("YES")
        else:
            print("NO")

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
